package main
import "fmt"

func main()  {
	fmt.Println("请输入您的密码")
	var str1 string
	fmt.Scanln(&str1)
	fmt.Println(str1)
	num := 2
	str4 := ""
	if len(str1) >= 8{
		num = num + 1
	}else {
		str4 = "密码长度没超过8"
	}
	num2,str2 := test1(num,str1)
	num3,str3 := test2(num2,str1)

	fmt.Println(num3,str2,str3,str4)
}

func test1(nu int,str1 string) (int,string) {
	var num2,num3,num4,num5 int
	str := ""
	for _,i := range str1{
		switch  {
		case i>=48 && i<=57:
			num2 = 1
		case i>=65 && i<=90:
			num3 = 1
		case i>=97 && i<=122:
			num4 = 1
		default:
			num5 = 1
		}
	}
	sum1 := num2 + num3 + num4 + num5
	if sum1 > 3{
		nu = nu + 1
	}else {
		str = "密码没有4种以上字符组成"
	}
	return nu,str
}


func test2(num int,str1 string)(int,string) {
	length := 0
	str := ""
	var nu string
	for _,i := range str1{
		if length == 0{
			nu = string(i)
			length = 1
		}else if length >= 1 && length<3{
			if nu == string(i){
				length++
			}else {
				length = 0
				nu = string(i)
			}
		}else {
			str = "重复次数超过3"
			return num, str
		}
	}
	return num + 1,str
}
